﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PanelFlowing : MonoBehaviour
{
    // Start is called before the first frame update

    public float FloatingRate;
    public float FloatingStrength;
    private bool floatingUp = false;
    void Start()
    {
        StartCoroutine(Floating());
        StartCoroutine(FloatingParaChange());
    }

    // Update is called once per frame
    void Update()
    {

    }
    IEnumerator Floating()
    {
        while (true)
        {
            yield return new WaitForEndOfFrame();
            GetComponent<Rigidbody>().velocity = new Vector3(0, floatingUp ? 1 : -1, 0) * FloatingStrength;
        }
    }

    IEnumerator FloatingParaChange()
    {
        while (true)
        {
            yield return new WaitForSeconds(FloatingRate);
            floatingUp = !floatingUp;
        }
    }
}
